package com.qf.mvc.controller;

import com.qf.mvc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("rest")
@ResponseBody
public class RestFullController {
    @RequestMapping("all")
    public List<User> getAllUser() {
        User user1 = new User();
        user1.setName("aaa");
        user1.setId(1);
        User user2 = new User();
        user2.setName("bbb");
        user2.setId(2);
        List<User> users = Arrays.asList(user1, user2);
        return users;
    }

    @RequestMapping("user")
    public User getAllUser(User user) {
        user.setId(123);
        return user;
    }
}
